home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tcclib.exe / FINDLEFT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-18  |  756 b   |  40 lines

  1. typedef struct {
  2.     int   x;
  3.     int   y;
  4.     int   Len;
  5.     int   Type;
  6.     char *Address;
  7.     int   EditFlag;
  8.     int   NumDecimals;
  9. } FieldStruc;
  10.  
  11. FindLeft( FieldStruc *Field, int pos, int NUMFIELDS )
  12. {
  13.     register int i;
  14.     register int choice = -1;
  15.     register FieldStruc *FS1, *FS3, *FS2=Field + pos;
  16.  
  17.     FS1 = Field;
  18.     for (i=0; i<NUMFIELDS; ++i) {
  19.         if ( i == pos )                 goto Increment;
  20.         if ( FS1->EditFlag == 0 )       goto Increment;
  21.         if ( FS1->y != FS2->y )         goto Increment;
  22.         if ( FS1->x > FS2->x )          goto Increment;
  23.         if ( choice == -1 ) {
  24.             choice = i;
  25.             FS3 = FS1;
  26.         }
  27.         else
  28.             if ( FS1->x > FS3->x ) {
  29.                 choice = i;
  30.                 FS3 = FS1;
  31.             }
  32. Increment:
  33.         FS1++;
  34.     }
  35.     if ( choice == -1 )
  36.         return( pos );
  37.     else
  38.         return( choice );
  39. }
  40.